package com.yanmaohu.nikita.data.structure;

import com.yanmaohu.nikita.data.expression.NameExpression;
import com.yanmaohu.nikita.data.function.FunctionBody;
import com.yanmaohu.nikita.data.function.ParameterList;

/**
 * @author Bright Lee
 */
public final class FunctionMember implements Member {

    private MemberModifier modifier;
    private NameExpression functionName;
    private ParameterList parameterList;
    private FunctionBody functionBody;

    public FunctionMember(MemberModifier modifier,
                          NameExpression functionName,
                          ParameterList parameterList,
                          FunctionBody functionBody) {
        this.modifier = modifier;
        this.functionName = functionName;
        this.parameterList = parameterList;
        this.functionBody = functionBody;
    }

    @Override
    public int getBeginIndex() {
        if (modifier != null) {
            return modifier.beginIndex();
        }
        return functionName.getBeginIndex();
    }

    @Override
    public int getEndIndex() {
        return functionBody.getEndIndex();
    }

    public MemberModifier getModifier() {
        return modifier;
    }

    public NameExpression getFunctionName() {
        return functionName;
    }

    public ParameterList getParameterList() {
        return parameterList;
    }

    public FunctionBody getStatementList() {
        return functionBody;
    }

}
